<template>
  <div>
    <dl v-for="item in arr" :key="item.id" @click="detail(item.id)">
      <dt>
        <img :src="'http://157.122.54.189:9060' + item.imgSrc" alt="" />
      </dt>
      <dd>
        <p class="dd1">{{ item.title }}</p>
        <p class="dd2">{{ item.from }}</p>
        <p class="dd3">{{ item.date }}</p>
      </dd>
    </dl>
  </div>
</template>

<script>
import { getConsult } from "../../../server/index";
export default {
  data() {
    return {
      arr: [],
    };
  },
  async created() {
    let list = await getConsult("http://157.122.54.189:9060/home/news");
    if (list.status === 200) {
      this.arr = list.body;
    }
  },
  methods: {
    detail(id) {
      console.log(id);
      uni.navigateTo({
        url: `/pages/home/consult/detail/index?id=${id}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
div {
  width: 100%;
  height: 100%;
  dl {
    width: 90%;
    margin: 0 auto;
    display: flex;
    padding-top: 40rpx;

    img {
      width: 150rpx;
      height: 150rpx;
      border-radius: 10rpx;
    }
    dd {
      flex: 1;
      margin-left: 30rpx;
      .dd1 {
        height: 40rpx;
        font-weight: 700;
        margin-top: 10rpx;
      }
      .dd2 {
        margin-top: 30rpx;
        font-size: 20rpx;
      }
      .dd3 {
        margin-top: 20rpx;
        font-size: 20rpx;
      }
    }
  }
}
</style>